export default class {
    public static wantArray<T>(data: T) {
        return Array.isArray(data) ? data : [];
    }

    public static debounce(action: Function, delay: number): () => void {
        let timer: any;
        return function (this: any, ...args: any) {
            timer && clearTimeout(timer);
            timer = setTimeout(() => {
                action.apply(this, args);
            }, delay);
        };
    }
}
